//
//  MJMyExamTableViewCell.m
//  MJ
//
//  Created by qiaoBu on 2017/12/8.
//  Copyright © 2017年 lina. All rights reserved.
//

#import "MJMyExamTableViewCell.h"
#import "MJMyHistoryExamsModel.h"

@interface MJMyExamTableViewCell ()

@property (nonatomic, strong) UIImageView *markImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *numberLabel;

@end

@implementation MJMyExamTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        [self commonInit];
    }
    return self;
}

- (void)commonInit{
   
    _markImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_markImageView];
    [_markImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.contentView.mas_left).offset(20);
        make.top.mas_equalTo(self.contentView.mas_top).offset(7.5);
        make.size.mas_equalTo(CGSizeMake(100, 65));
    }];
    
    _titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(_markImageView.mas_right).offset(10);
        make.top.mas_equalTo(self.contentView.mas_top).offset(24);
    }];
    _titleLabel.textColor = RGBColor(102, 102, 102);
    _titleLabel.font = [UIFont systemFontOfSize:14];
    _titleLabel.textAlignment = NSTextAlignmentLeft;
    
    _numberLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_numberLabel];
    [_numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(_markImageView.mas_right).offset(10);
        make.top.mas_equalTo(_titleLabel.mas_bottom).offset(15);
    }];
    _numberLabel.textColor = RGBColor(191, 191, 191);
    _numberLabel.font = [UIFont systemFontOfSize:14];
    _numberLabel.textAlignment = NSTextAlignmentLeft;
    
    
    UIView *grayView = [[UIView alloc] init];
    [self.contentView addSubview:grayView];
    [grayView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.right.bottom.mas_equalTo(self.contentView);
        make.height.mas_equalTo(10);
    }];
    grayView.backgroundColor = RGBColor(242,242,242);
    
    
    UIView *topLine = [[UIView alloc] init];
    [self.contentView addSubview:topLine];
    [topLine mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.right.top.mas_equalTo(self.contentView);
        make.height.mas_equalTo(0.5);
    }];
    topLine.backgroundColor = RGBColor(229,229,229);
    
    UIView *bottomLine = [[UIView alloc] init];
    [self.contentView addSubview:bottomLine];
    [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.right.top.mas_equalTo(grayView);
        make.height.mas_equalTo(0.5);
    }];
    bottomLine.backgroundColor = RGBColor(229,229,229);
    
}

- (void)setModel:(ExamContentModel *)model{
    
    _model = nil;
    _model = model;
    _titleLabel.text = [NSString stringWithFormat:@"%@",_model.title];
    _numberLabel.text = [NSString stringWithFormat:@"%@%@",_model.uptm,@"人测试过"];
    [_markImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",_model.pic]]];
}

@end
